package com.lcs.springcloud.controller;


import com.lcs.springcloud.feign.ProviderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("consumer")
public class ProviderController
{
    private final RestTemplate restTemplate;
    private final ProviderFeign providerFeign;
    @Autowired
    public ProviderController(RestTemplate restTemplate, ProviderFeign providerFeign)
    {
        this.restTemplate=restTemplate;
        this.providerFeign=providerFeign;
    }

    @GetMapping("/getPort")
    public String getPort()
    {
        String str = providerFeign.getPort();
//        String str = restTemplate.getForObject("http://nacos-provider/provider/getPort", String.class);
        return "我是消费者,他是"+str;
    }
}